package value_compare.component;

import value_compare.framework.BaseSameTypeCompare;
import value_compare.framework.CompareOperator;

import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Set;

import static java.util.Arrays.asList;
import static value_compare.framework.CompareOperator.*;

/**
 * @author lihao
 * @since 2019-11-03 22:22:21
 */
public class BigDecimalCompare extends BaseSameTypeCompare<BigDecimal> {

    private static Set<CompareOperator> supported = new HashSet<CompareOperator>(){{
        this.addAll(asList(gt,ge,lt,le,eq,ne));
    }};

    public BigDecimalCompare(BigDecimal left, BigDecimal right) {
        super(left, right);
    }

    @Override
    public Set<CompareOperator> supported() {
        return supported;
    }

    @Override
    public boolean gt() {
        return this.left.compareTo(this.right) > 0;
    }

    @Override
    public boolean ge() {
        return this.left.compareTo(this.right) >= 0;
    }

    @Override
    public boolean lt() {
        return this.left.compareTo(this.right) < 0;
    }

    @Override
    public boolean le() {
        return this.left.compareTo(this.right) <= 0;
    }

    @Override
    public boolean eq() {
        return this.left.compareTo(this.right) == 0;
    }

    @Override
    public boolean ne() {
        return this.left.compareTo(this.right) != 0;
    }
}
